{include file="public/header"}
<style>
    .layui-table{border: 1px solid #000;}
</style>
<body>
    <fieldset class="layui-elem-field">
        <legend>流水汇总列表</legend>
        <div class="layui-field-box">
            <form id="seachForm" method="" action="" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width:92px;">上传excel</label>
                    <div class="layui-input-block">
                        <input type="file" name="file" class="layui-upload-file" lay-ext="xls">
                    </div>
                </div>
               
            </form>

            <div class="layui-tab" lay-filter="demo">
                <ul class="layui-tab-title">
                    <li class="layui-this">未结算</li>
                    <li>已结算</li>

                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <table class="layui-table" lay-even>
                            <thead>
                                <tr>
                                    <th>代理商</th>
                                    <th>收款费率</th>
                                    <th>还款费率</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>{$data.chnlName}</td>
                                    <td>{$data.getfee}</td>
                                    <td>{$data.payfee}</td>
                                </tr>
                            </tbody>
                        </table>
                        {if $data && array_key_exists('children',$data)} 
                        {volist name="data.children" id="vo"}
                        {if $vo.file}
                        <table class="layui-table" lay-even>
                            <thead>
                                <tr>
                                    <th>下级代理商</th>
                                    <th>收款费率</th>
                                    <th>还款费率</th>
                                    <th>收款费率差</th>
                                    <th>还款费率差</th>
                                    <th></th>
                                    <th></th>
                                </tr>
                                <tr class="bgf2">
                                    <th>{$vo.chnlName}</th>
                                    <th>{$vo.fee.getfee}</th>
                                    <th>{$vo.fee.payfee}</th>
                                    <th>{$vo.fee.getfee_differ}</th>
                                    <th>{$vo.fee.payfee_differ}</th>                                   
                                    <th></th>
                                    <th></th>
                                </tr>
                            </thead>
                            
                            <thead>
                                <tr>
                                    <th>代理商全称</th>
                                    <th>结算周期</th>
                                    <th>收款总金额</th>
                                    <th>还款总金额</th>
                                    <th>小计</th>
                                    <th>结算状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {volist name="vo.file" id="v"}
                                <tr>
                                    <td>{$v.chnlName}</td>
                                    <td>{$v['time']}</td>
                                    <td>{$v['get_sum']}</td>
                                    <td>{$v['pay_sum']}</td>
                                    <td>{$v['sum']}</td>
                                    <td>{$v['status_name']}</td>
                                    <td>
                                        <a class="layui-btn layui-btn-normal " href="{:url('Trade/show',['id'=>$v.trade_id,'agent'=>$v.chnlName,'agent_id'=>$v.chnlId])}">明细</a>
                                        <a class="layui-btn "   href="{:url('Trade/statement',['id'=>$v.trade_id,'agent_id' => $v.chnlId,'parentagent_id'=>$data.chnlId,'getfee_differ'=>$vo.fee.getfee_differ_num,'payfee_differ'=>$vo.fee.payfee_differ_num])}">结算</a>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                            {/if}
                        </table>
                        {/volist} 
                        {/if}
                    </div>
                    <div class="layui-tab-item">
                          <table class="layui-table" lay-even>
                            <thead>
                                <tr>
                                    <th>代理商</th>
                                    <th>还款费率</th>
                                    <th>收款费率</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>{$data.chnlName}</td>
                                    <td>{$data.payfee}</td>
                                    <td>{$data.getfee}</td>
                                </tr>
                            </tbody>
                        </table>
                        {if $data && array_key_exists('children',$data)} 
                        {volist name="data.children" id="vo"}
                        {if $vo.settle_file}
                        <table class="layui-table" lay-even>
                            <thead>
                                <tr>
                                    <th>下级代理商</th>
                                    <th>还款费率</th>
                                    <th>收款费率</th>
                                    <th>还款费率差</th>
                                    <th>收款费率差</th>
                                    <th></th>
                                    <th></th>
                                </tr>
                                <tr class="bgf2">
                                    <th>{$vo.chnlName}</th>
                                    <th>{$vo.fee.payfee}</th>
                                    <th>{$vo.fee.getfee}</th>
                                    <th>{$vo.fee.payfee_differ}</th>
                                    <th>{$vo.fee.getfee_differ}</th>
                                    <th></th>
                                    <th></th>
                                </tr>
                            </thead>
                            
                            <thead>
                                <tr>
                                    <th>代理商全称</th>
                                    <th>结算周期</th>
                                    <th>收款总金额</th>
                                    <th>还款总金额</th>
                                    <th>小计</th>
                                    <th>结算状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {volist name="vo.settle_file" id="v"}
                                <tr>
                                    <td>{$v.chnlName}</td>
                                    <td>{$v['time']}</td>
                                    <td>{$v['get_sum']}</td>
                                    <td>{$v['pay_sum']}</td>
                                    <td>{$v['sum']}</td>
                                    <td>{$v['status_name']}</td>
                                    <td>
                                        <a class="layui-btn layui-btn-normal " href="{:url('Trade/show',['id'=>$v.trade_id,'agent'=>$v.chnlName,'agent_id'=>$v.chnlId])}">明细</a>
                                        
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                            {/if}
                        </table>
                        {/volist} 
                        {/if}
                    </div>
                </div>
            </div>


        </div>
    </fieldset>
    {include file="public/footer"}
    <script>
        layui.use(['upload', 'layer'], function () {
            layui.upload({
                url: "{:url('addTradeBill')}",
                before: function () {
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                },
                success: function (res) {

                    if (res.errorCode > 0) {
                        dialog.error(res.msg);
                    } else {
                        dialog.success(res.msg, function () {
                            location.reload();
                        });
                    }
                }

            });
        });

        layui.use('element', function () {
            var element = layui.element();
            //一些事件监听
            element.on('tab(demo)', function (data) {
                console.log(data);
            });
        });
    </script>
</body>

</html>